作者:冷嘲热讽714 | 来源:互联网 | 2023-09-12 18:15
一、登入gitlab服务并配置###---登入gitlab服务并配置~~~登录gitlab服务:http:gitlab.test.com初始默认需要修改密码:password~~~
一、登入gitlab服务并配置
### --- 登入gitlab服务并配置
~~~ 登录gitlab服务:http://gitlab.test.com/ 初始默认需要修改密码:password
~~~ 使用:用户名:root,密码:password登入gitlab
二、让他、导入ssh-key生成ssh key的公钥
### --- 让他、导入ssh-key生成ssh key的公钥
~~~ Administration——>Settings——>SSH Keys——>key:公钥——>Add key
[root@k8s-master01 ~]# ssh-keygen
[root@k8s-master01 ~]# cat /root/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIYuiDOEj2bzsZtyCOCSKYjhhO9iuxU0A7JEbnAG+17WYbjw3WhMouz1cmEKLXrSeWDnbGlL0Ur3iQA5hODpuTxWJojdizAWjmQyVANNh2/Rh+QFUS+NPu9bLNpTZTHtD54vNcDVlw8/LnrnGSdH/5Z/a5gC2adUcxWp6qE6LrfR497h78Umu5599B+PSXCH9o/kzyoeiQ/bytoijPpHrNhbFfUbImo6672yDuyDwZOpkJOEJ3hGUXEC4BcvLabbjAqT1CupYCDebGA5Tac3vPzGHlt8Pm0DY2v4xrwB3S8d/zK2Q2b57lFHtHIymby3H/HZj5ka7ypWb8KJ5ON6Jj root@k8s-master01
三、创建一个组:kubernetes-guide
### --- 创建一个组:kubernetes-guide
~~~ Projects——>Your projects——>Create a group——>Group name:kubernetes-guide——>Create group
~~~ 在这个组里创建project:New Project——>Project name:Spring-cloud-demo——>Create project
四、将创建的项目克隆到k8s-master01中
### --- 将创建的git项目仓库拷贝到k8s-master01
~~~ 配置本地主机hosts文件
[root@k8s-master01 CICD]# cat /etc/hosts
192.168.1.16 gitlab.test.com
### --- 安装Git客户端工具
[root@gitlab CICD]# yum -y install git
~~~ # 下载项目到本地
[root@k8s-master01 CICD]# git clone git@gitlab.test.com:kubernetes-guide/spring-cloud-demo.git
Cloning into 'spring-cloud-demo'...
warning: You appear to have cloned an empty repository.
### --- 将之前的java应用拷贝到该项目中
~~~ 更改过配置,重新reset
[root@k8s-master01 spring-cloud-demo2]# git reset --hard
HEAD is now at 0e282fe filter
### --- 将Java项目文件拷贝到仓库中
[root@k8s-master01 JVM]# cp -rp spring-cloud-demo2/* /root/README/CICD/spring-cloud-demo/
[root@k8s-master01 spring-cloud-demo]# pwd
/root/README/CICD/spring-cloud-demo
[root@k8s-master01 spring-cloud-demo]# git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add ..." to include in what will be committed)
#
# LICENSE
# README.md
# pom.xml
# spring-cloud-commons/
# spring-cloud-eureka/
# spring-cloud-gateway/
# spring-cloud-nacos-discovery/
# spring-cloud-user/
nothing added to commit but untracked files present (use "git add" to track)
### --- 推送到远程仓库中
[root@k8s-master01 spring-cloud-demo]# git add . // add .表示把当前目录下所有文件添加进去
~~~ # 设置用户名及邮箱
[root@k8s-master01 spring-cloud-demo]# git config --global user.email "yanqi@yeah.net"
[root@k8s-master01 spring-cloud-demo]# git config --global user.name "yanqi"
[root@k8s-master01 spring-cloud-demo]# git commit -m "add README"
~~~ # push到远程仓库中
[root@k8s-master01 spring-cloud-demo]# git push -u origin master
Counting objects: 125, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (82/82), done.
Writing objects: 100% (125/125), 40.19 MiB | 1.90 MiB/s, done.
Total 125 (delta 14), reused 0 (delta 0)
remote: Resolving deltas: 100% (14/14), done.
To git@gitlab.test.com:kubernetes-guide/spring-cloud-demo.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
五、关闭Auto DevOps
### --- 关闭Auto DevOps
~~~ Admin Area——>settings——>CI/CD——>AutoDevOps
~~~ ——>取消对勾:Default to Atuo DevOps pipeline——>Save changes
### --- 关闭全局的配置
~~~ Admin Area——>Settings——>CI/CD——>Expand
~~~ ——>取消对勾:Defatult to Auto DevOps pileline for all projects——>Save changes
六、配置jenkins固定用户的key访问权限
### --- 配置jenkins固定用户的key访问权限
~~~ 当前的用户是管理员用户,使用管理员用户的key可以对gitlab的key都是有权限的
~~~ 若是没有jenkins配置不是管理员用户的情况下,
~~~ 需要在每个项目下把jenkins构建的用户加入到权限中
~~~ spring-cloud-demo——>Settings——>Members
~~~ ——>choose a role permission:developer或者reporter——>保存即可
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
——W.S.Landor